home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 001 / pibt3sp1.arc / ERRORHAN.PAS < prev    next >
Pascal/Delphi Source File  |  1985-08-30  |  3KB  |  70 lines

  1. (*----------------------------------------------------------------------*)
  2. (*     Error_Handler --- Handle program aborts by exiting gracefully    *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Error_Handler( ErrNo , ErrAddr : INTEGER );
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Error_Handler                                        *)
  10. (*                                                                      *)
  11. (*     Purpose:    Handle PibTerm program aborts by halting gracefully  *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Error_Handler( ErrNo , ErrAddr : INTEGER );                   *)
  16. (*                                                                      *)
  17. (*           ErrNo    --- error number/type                             *)
  18. (*           ErrAddr  --- address where error occurred                  *)
  19. (*                                                                      *)
  20. (*     Remarks:                                                         *)
  21. (*                                                                      *)
  22. (*        This routine needs to be cleaned up to handle file closing    *)
  23. (*        better at some point.                                         *)
  24. (*                                                                      *)
  25. (*----------------------------------------------------------------------*)
  26.  
  27. BEGIN (* Error_Handler *)
  28.                                    (* Send notice of fatal error (also to  *)
  29.                                    (* caller in host mode) and quit.       *)
  30.    IF Host_Mode THEN
  31.       BEGIN
  32.          Async_Send_String(' ');
  33.          Async_Send_String('Sorry, there has been a system error, please call back later');
  34.          Async_Send_String('Disconnecting....');
  35.          WRITELN;
  36.          WRITELN('Sorry, there has been a system error, please call back later');
  37.          WRITELN('Disconnecting....');
  38.       END
  39.    ELSE
  40.       BEGIN
  41.          WRITELN;
  42.          WRITELN('Sorry, there has been a serious PibTerm error.');
  43.       END;
  44.  
  45.                                    (* Report error number and type *)
  46.  
  47.    WRITE('Error number: ',LO( ErrNo ), ' = ' );
  48.  
  49.    CASE HI( ErrNo ) OF
  50.       0: WRITE('User break');
  51.       1: WRITE('I/O error');
  52.       2: WRITE('Run time error');
  53.       ELSE
  54.          WRITE('Unknown Error');
  55.    END (* CASE *);
  56.  
  57.    WRITELN(' at address ',ErrAddr,' (decimal)');
  58.  
  59.                                    (* Turn off serial port I/O     *)
  60.    Async_Close;
  61.                                    (* Turn off fatal error handler *)
  62.    Int24Off;
  63.                                    (* Quit                         *)
  64.  
  65.    WRITELN('PibTerm aborting ... ');
  66.  
  67.    HALT( 2 );
  68.  
  69. END   (* Error_Handler *);
  70.